package t1008;


import java.util.Scanner;

/**
 * @姓名 张东升
 * @日期 2025年04月2025/4/6日、
 * 8 ASfdK56M 32 435 233 43 55 0
 */
public class Main {

    public static void main(String[] args) {
        Node intHead =  new Node();
        Node stringHead = new Node();
        Scanner scanner = new Scanner(System.in);
        // 创建string链表
        createString(stringHead,scanner);

        // 创建数字连表
        createInt(intHead,scanner);
        reserve(stringHead);
        display(stringHead, true);
        toUpdate(stringHead);
        display(stringHead, true);
        delete(intHead);
        display(intHead, false);

    }
    //删除偶数
    public static void delete(Node head){
        Node node = head.next;
        Node pre = head;
        while (node!=null){
            if (node.data % 2 == 0){
                pre.next = node.next;

            }else {
                pre.next = node;
                pre = pre .next;
            }
            node = node.next;
        }
    }
    public static void toUpdate(Node head){
        Node node = head.next;
        while (node != null) {

            if (node.data >= 'a' && node.data <= 'z'){
                node.data += ('A' - 'a');
            }

            node = node.next;
        }
    }


    public static void reserve( Node head){
         Node prev = null;
         Node current = head.next;
         Node next = null;
        while (current != null) {
            next = current.next;
            current.next = prev;
            prev = current;
            current = next;
        }
        head.next = prev;
    }
    public static void createInt(Node head,Scanner scanner) {
        Node node = head;
        int n = scanner.nextInt();
        while (n != 0){
            node.next = new Node(n,null);
            n = scanner.nextInt();
            node = node.next;
        }

    }
    public static void createString(Node head,Scanner scanner) {
        int n = scanner.nextInt();
        Node node = head;
        String str = scanner.next();
        for (int i = 0; i < n; i++) {
            node.next = new Node(str.charAt(i),null);
            node = node.next;
        }
    }
    
    public static void display(Node head,boolean isChar){
        Node next = head.next;
        System.out.print("Data:");
        if (isChar){
            while (next!=null){
                System.out.printf( "%c" , next.data);
                System.out.print( " ");
                next = next.next;
            }
        }else {
            while (next!=null){
                System.out.print(next.data + " ");
                next = next.next;
            }   
        }
       
        System.out.println();
    }
}

class Node {
    public int data;
    public
    Node next;

    public Node() {
    }

    public Node(int data, Node next) {
        this.data = data;
        this.next = next;
    }
}
